const axios = require("axios");
const FormData = require('form-data');

let token;
const projectId = 72088;
// const authOrderId = '1753718230513778688';
const authOrderId = '1754378696323461120'

function login() {
    const formData = new FormData();
    formData.append('username', 'a123');
    formData.append('password', 'a123');
    axios.post("http://dami.ifzbs.cn:8881/public/userLogin", formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(res => {
        if (res.data.flag) {
            console.log(res.data);
            token = res.data.data.usertoken;
            // getauthcode();
            // getorderinfo();
            // getappauthcode();
            // createTaskApi();
        }
    });
}
function getappauthcode() {
    const formData = new FormData();
    formData.append('token', token);
    formData.append('orderId', authOrderId);
    axios.post("http://dami.ifzbs.cn:8884/public/getauthcode", formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(res => {
        console.log(res.data);
    });
}
function getauthcode() {
    const formData = new FormData();
    formData.append('token', token);
    formData.append('orderId', authOrderId);
    axios.post("http://dami.ifzbs.cn:8884/public/getresult", formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(res => {
        console.log(res.data);
    });
}

function getorderinfo() {
    const formData = new FormData();
    formData.append('token', token);
    formData.append('orderId', authOrderId);
    axios.post("http://dami.ifzbs.cn:8881/public/getorderinfo", formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(res => {
        console.log(res.data);
    });
}

function createTaskApi() {
    console.log("createTaskApi");
    const formData = new FormData();
    formData.append('token', token);
    formData.append('appId', projectId);
    formData.append('qrCode', 'https://open.weixin.qq.com/connect/confirm?uuid=061OHIuk0iGC000R');
    axios.post("http://dami.ifzbs.cn:8881/createTaskApi", formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }).then(res => {
        console.log(res.data);
    });
}

login();